#ifndef sheet_h
#define sheet_h

#include <common/include/interface.h>
#include <common/include/typedef.h>
using cmn::kcstr;
using cmn::kcwstr;

namespace excel{
	class sheet;	//entire sheet
	class entry;	//each line
	class cell;		//each grid.

	enum column_var_type{
		cv_id,		//I
		cv_int,		//N
		cv_float,	//F
		cv_str,		//S
	};
	class entry_iterator : public cmn::interface_t, public cmn::noncopyable
	{
	public:
		virtual bool next() = 0;

		virtual bool is_equal(const entry_iterator* rhs) = 0;

		virtual entry* get_entry() = 0;
	};


	class sheet : public cmn::interface_t, public cmn::noncopyable
	{
	public:
		virtual entry*	get_entry(int id)		= 0;

		virtual int		get_type(int column)	= 0;

		virtual kcwstr	get_title(int column)	= 0;

		virtual int		get_column(kcwstr title)= 0;

		virtual int		get_column_count()		= 0;

		virtual int		get_id_column()			= 0;

		virtual entry_iterator*	first()			= 0;

		virtual entry_iterator*	last()			= 0;
	};

	class cell_iterator : public cmn::interface_t, public cmn::noncopyable
	{
	public:
		virtual bool next()			= 0;

		virtual cell* get_cell()	= 0;

		virtual bool is_equal(const cell_iterator* rhs) = 0;
	};

	class entry : public cmn::interface_t, public cmn::noncopyable
	{
	public:
		virtual cell*	get_cell(int column)	= 0;

		virtual cell*	get_cell(kcwstr title)	= 0;

		virtual cell*	get_id_cell()			= 0;

		virtual sheet*	get_sheet()				= 0;

		virtual int		get_id()				= 0;

		virtual cell_iterator*	first()			= 0;

		virtual cell_iterator*	last()			= 0;
	};

	class cell : public cmn::interface_t, public cmn::noncopyable
	{
	public:
		virtual int		get_type()	= 0;

		virtual int		to_int()	= 0;

		virtual float	to_float()	= 0;

		virtual kcstr	to_string()	= 0;

		virtual kcwstr	to_wstring()= 0;

		virtual int		get_column()= 0;

		virtual entry*	get_entry()	= 0;

		virtual sheet*	get_sheet()	= 0;
	};

	sheet* load_sheet(kcstr filename, kcstr sheetname = nullptr);
}
#endif 